import sys
import time
import re

def parse_date(d):
    if d is None:
        return None
    
    date = d.split("-")[0].split("+")[0].strip().split("\t")[0]
    date = date.replace("GMT", "").replace("EDT", "").replace("EST", "")
    date = date.replace("UT", "").replace("PST", "").replace(" C", "")
    date = date.replace("DT", "").replace("Pacific Standard Time", "")
    date = date.replace("BST", "").replace(" P", "").replace("MET", "")
    date = date.replace("{%LOGWITHID:", "").replace(" AM", "")
    date = date.replace("Wen", "Wed").replace(" AM", "").replace("Tues", "Tue")
    date = date.replace("Tueday", "Tuesday").replace("%AMS_MESSAGE_DATE%", "")
    date = date.replace(" MST", "").replace("ET", "")
    date = date.replace("Eastern Standard Time", "")
    date = date.replace("AM", "").replace("PM", "")
    date = re.sub(r'(:\d\d)\s\d{4}', r'\1', date)
    date = re.sub(r'\s(\d:\d\d)', r' 0\1', date)
    date = re.sub(r'\s(\d),', r' 0\1,', date)
    date = re.sub(r':(\d\d)\d', r':\1', date)
    date = re.sub(r'(\d)\sM$', r'\1', date)
    date = re.sub(r'(\d\d:\d\d:\d\d)\s\1', r'\1', date)
    date = re.sub(r'^,\s', r'', date)
    date = re.sub(r'[\sa-zA-Z]*$', r'', date)
    date = date.strip()
    
    try:
        date.decode("utf-8")
    except UnicodeDecodeError:
        return None
    
    if not date:
        return None
    
    
    exceptions = ["@@DATE"]
    
    if date in exceptions:
        return None
    
    if "61520" in date:
        return None
    
    try:
        return time.strptime(date, "%a, %d %b %Y %H:%M:%S %Z")
    except ValueError:
        pass
    
    try:
        return time.strptime(date, "%a, %d %b %Y %H:%M:%S")
    except ValueError:
        pass
    
    try:
        return time.strptime(date, "%d %b %Y %H:%M:%S")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%d %b %y %H:%M:%S")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%d %b %y %H:%M")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%B %d, %Y %H:%M:%S")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%a, %d %b %y %H:%M:%S")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%a, %d %b %Y %H:%M")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%a, %d %b %Y %H:%M:%S")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%a, %d %b %Y")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%b %d %Y %H:%M:%S")
    except ValueError, e:
        pass
    
    try:
        return time.strptime(date, "%A, %d %B %Y %H:%M:%S")
    except ValueError, e:
        return None

def get_year(d):
    if d is None:
        return "Unsorted"
    so = re.search("[^\w\d]([0-9][0-9][0-9][0-9])([^\w\d]|$)", d)
    if so is not None:
        year = int(so.group(1))
        if year > 1950 and year < 2100:
            return year

    so = re.search("(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*(\d\d)([^\w\d]|$)", d)
    if so is not None:
        year = int(so.group(2))
        if year > 80:
            return year + 1900
        elif year < 12:
            return year + 2000
    
    return "Unsorted"
        

if __name__ == "__main__":
    for line in sys.stdin:
        l = line.strip()
        if len(l) == 0:
            continue
        d = parse_date(l)
        if d is None:
            print l + "\tBad input"
        elif d == False:
            print l + "\tcannot be parsed"
        else:
            print l + "\tparsed"
        
